import cv2 as cv
import numpy as np

camera = cv.VideoCapture(0)
if not camera.isOpened():
    print("[ERROR] Open camera failed")
while True:
    ret, frame = camera.read()
    imgHSV = cv.cvtColor(frame, cv.COLOR_BGR2HSV)

    lower_blue = np.array([80, 120, 120])
    upper_blue = np.array([130, 255, 255])

    blueMask = cv.inRange(imgHSV, lower_blue, upper_blue)

    res = cv.bitwise_and(frame, frame, mask=blueMask)

    cv.imshow("img", frame)
    cv.imshow("mask", blueMask)
    cv.imshow("blue", res)

    key = cv.waitKey(1) & 0xFF
    if key == ord('q'):
        break

camera.release()
cv.destroyAllWindows()
